package com.e1xp.deport_management_system.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author E1xP@foxmail.com
 * @version 1.0
 * @PACKAGE_NAME com.e1xp.deport_management_system.utils
 * @CLASS_NAME MD5
 * @Description TODO MD5加密工具类
 * @Date 2021/4/28 上午 10:48
 **/
public class MD5 {
    /**
     * 用于获取md5小写32位
     * @param str 待md5字符串
     * @return String md5后字符串
     */
    public static String md5L32(String str){
        String result=null;
        try {
            MessageDigest md5=MessageDigest.getInstance("md5");
            byte[] bytes=md5.digest(str.getBytes());
            StringBuffer stringBuffer=new StringBuffer();
            for(byte b:bytes){
                int bt= b&0xff;
                if(bt<16){
                    stringBuffer.append(0);
                }
                stringBuffer.append(Integer.toHexString(bt));
            }
            result=stringBuffer.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return result;
    }
}
